home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 October: Mac OS SDK / Dev.CD Oct 00 SDK1.toast / Development Kits / Mac OS / Appearance SDK 1.0.4 / Appearance Sample Code / Source / TrapTools.c < prev    next >
Encoding:
Text File  |  1999-07-16  |  1.5 KB  |  71 lines  |  [TEXT/CWIE]

  1. /*
  2.     File:        TrapTools.c
  3.  
  4.     Contains:    Trap utility functions.
  5.  
  6.     Version:    Appearance 1.0 SDK
  7.  
  8.     Copyright:    © 1997 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     File Ownership:
  11.  
  12.         DRI:                Edward Voas
  13.  
  14.         Other Contact:        7 of 9, Borg Collective
  15.  
  16.         Technology:            OS Technologies Group
  17.  
  18.     Writers:
  19.  
  20.         (edv)    Ed Voas
  21.  
  22.     Change History (most recent first):
  23.  
  24.          <2>     9/11/97    edv        Fix header.
  25.          <1>     9/11/97    edv        First checked in.
  26. */
  27.  
  28. //------------------------------------------------------------------------------
  29. //    Includes
  30. //------------------------------------------------------------------------------
  31.  
  32. #include <Traps.h>
  33. #include "TrapTools.h"
  34.  
  35. //------------------------------------------------------------------------------
  36. //    Private prototypes
  37. //------------------------------------------------------------------------------
  38.  
  39. static int NumToolboxTraps();
  40.  
  41. //------------------------------------------------------------------------------
  42. //    Implementation
  43. //------------------------------------------------------------------------------
  44.  
  45. int NumToolboxTraps()
  46. {
  47.     if (NGetTrapAddress(_InitGraf,ToolTrap) == NGetTrapAddress(0xAA6E,ToolTrap))
  48.         return(0x200);
  49.     else
  50.         return(0x400);
  51. }
  52.  
  53.  
  54. TrapType GetTrapType(short theTrap)
  55. {
  56.     return((theTrap & 0x0800) ? ToolTrap : OSTrap);
  57. }
  58.  
  59. Boolean TrapAvailable(short theTrap)
  60. {
  61.     TrapType    tType;
  62.     
  63.     tType = GetTrapType(theTrap);
  64.     if (tType == ToolTrap) {
  65.         theTrap = theTrap & 0x07FF;
  66.         if (theTrap >= NumToolboxTraps())
  67.             theTrap = _Unimplemented;
  68.     }
  69.     return(NGetTrapAddress(theTrap,tType) != NGetTrapAddress(_Unimplemented,ToolTrap));
  70. }
  71.